import wxversion
wxversion.select("2.8")
import wx
import wx.aui

import wx.py as py

import MDIChildFrame1

class ChildFrame(wx.aui.AuiMDIChildFrame):
    def __init__(self, parent, count):
        wx.aui.AuiMDIChildFrame.__init__(self, parent, -1,
                                         title="Child: %d" % count)
        #p = wx.Panel(self)
        p = wx.TextCtrl(self, -1)
        wx.StaticText(p, -1, "This is child %d" % count, (10,10))
        p.SetBackgroundColour('light blue')

        sizer = wx.BoxSizer()
        sizer.Add(p, 1, wx.EXPAND)
        self.SetSizer(sizer)
        
        wx.CallAfter(self.Layout)

class MDIParentFrame1(wx.aui.AuiMDIParentFrame):
    def __init__(self, parent):
        wx.aui.AuiMDIParentFrame.__init__(self, parent, -1, name='',
              pos=wx.Point(355, 241), size=wx.Size(662, 532),
              style=wx.DEFAULT_FRAME_STYLE | wx.VSCROLL | wx.HSCROLL,
              title=u'PyMatLab')
        self._mgr = wx.aui.AuiManager()
        self._mgr.SetManagedWindow(self)

        #add content pane
        self.content = wx.Panel(self, -1)
        self._mgr.AddPane(self.content, wx.aui.AuiPaneInfo().
                          Name("ctx").Caption("Text Pane").
                          Right().CloseButton(True).MaximizeButton(True))
        self._mgr.GetPane("ctx").Show()

        #add PyShell pane
        self._mgr.AddPane(self.CreateShell(), wx.aui.AuiPaneInfo().
                          Name("shell").Caption("shell").
                          Bottom().Layer(1).Position(1).CloseButton(True).MaximizeButton(True))
        self._mgr.GetPane("shell").Show().Bottom().Layer(0).Row(0).Position(0)

        #add ChildFrame
        child = ChildFrame(self, 0)
        child.Maximize()
#        self._mgr.AddPane(child, wx.aui.AuiPaneInfo().
#                          Name("child").Caption("child").
#                          Center().Layer(0).Position(0).CloseButton(True).MaximizeButton(True))
#        self._mgr.GetPane("child").Show()
#        #.Show(True)

        self._mgr.Update()

    def CreateShell(self):
        return py.shell.Shell(self, -1, introText="Hello")

class BoaApp(wx.App):
    def OnInit(self):
        self.main = MDIParentFrame1(None)
        self.main.Show()
        self.SetTopWindow(self.main)
        return True

def main():
    application = BoaApp(0)
    application.MainLoop()

if __name__ == '__main__':
    main()
